<template>
<div>
  <div>
    <i class="el-icon-discount" style="color: red;font-size: 20px"></i>
    <span style="font-size: 20px"><b>视频管理</b></span></div><br>
  <div><i class="el-icon-arrow-right" style="color: red;font-size: 15px"></i>
    <span style="font-size: 15px"><b>视频审核</b></span></div><br>
  <el-form  ref="ruleForm"  class="demo-ruleForm"  style="position: relative;left: 30%;width: 500px" >
  <el-form-item  style="width: 400px">
          <span slot="label">
      	<span style="font-size: 15px">视频标题</span>
        </span>
    <el-input v-model="form.videotitle" maxlength="15"  show-word-limit :disabled="true"></el-input>
  </el-form-item>
  <el-form-item>
    <span style="font-size: 15px">视频正文</span>
    <VideoShow :src=form.videoaddr videoWidth=500px videoHegiht=500px ></VideoShow>
  </el-form-item>
  <el-form-item  prop="desc">
            <span slot="label">
      	<span style="font-size: 15px">视频简介</span>
        </span><br>
    <el-input type="textarea" v-model="form.brief" show-word-limit style="width: 600px;color: black" readonly="readonly" ></el-input>
  </el-form-item>
    <el-form-item  style="width: 400px">
          <span slot="label">
      	<span style="font-size: 15px">创建时间</span>
        </span>
      <el-input v-model="form.createtime" maxlength="10"  show-word-limit :disabled="true" ></el-input>
    </el-form-item>
</el-form>
  <div style="display:flex;align-items:center;justify-content:center">
  <el-button type="danger" @click="del()">审核拒绝</el-button>
  <el-button type="success" @click="suc()">审核通过</el-button>
  </div>
</div>
</template>

<script>
import VideoShow from "../video/VideoShow";
export default {
  name: "addfood",
  components:{
    VideoShow:VideoShow
  },
  data() {
    return {
      fileList: [],
      form: {
        id:"",
        videotitle:"",
        videoaddr:"",
        brief:"",
        createtime:"",
      }
    }
  },
  methods: {
    suc:function () {
        var data = {
          'audit':1,
          'id': this.form.id
        };
        console.log(data)
        var url='/video';
        this.$axios.put(url,data)
          .then( (res)=> {
            if (res.data.code === 0) {
              this.$message({message:"审核成功！", type: 'success'})
              // function myMessage() {
                this.$router.push({path:'/videode'});
              // }
              // setTimeout(myMessage, 1000);
            }
            else {
              this.$message({message:"审核失败！", type: 'error'})
            }
          }).catch(function (error) {
          console.log(error);
        } );
      },
    del:function () {
      var data = {
        'audit':2,
        'id': this.form.id
      };
      console.log(data)
      var url='/video';
      this.$axios.put(url,data)
        .then( (res)=> {
          if (res.data.code === 0) {
            this.$message({message:"审核成功！", type: 'success'})
            // function myMessage() {
            this.$router.push({path:'/videode'});
            // }
            // setTimeout(myMessage, 1000);
          }
          else {
            this.$message({message:"审核失败！", type: 'error'})
          }
        }).catch(function (error) {
        console.log(error);
      } );
    },
    indexs:function(){
      //根据接收到video的id信息并展示
      var id=this.$route.query.videoid;
      console.log(id);
      var url="/video/"+id;
      this.$axios.get(url)
        .then( (res)=> {
          console.log(res)
            this.form.id=res.data.data.id;
            this.form.videotitle=res.data.data.videotitle;
            this.form.videoaddr=res.data.data.videoaddr;
            this.form.brief=res.data.data.brief;
            this.form.createtime=res.data.data.createtime;
           console.log(this.form)
        }).catch(function (error) {
        console.log(error);
      } );
    },
  },
  created(){
    //自动加载indexs方法
    this.indexs();
  },
}
</script>

<style scoped>

</style>
